package net.roostertech.bta2dpfixer;

import java.util.Set;

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.os.Bundle;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class BTFixerMain extends Activity {

	private final String LOGTAG = "BTFixer";


	DeviceDAO dao;
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();

		if (btAdapter == null) {
			throw new RuntimeException("Can't create bt device");
		}

		Set<BluetoothDevice> pairedDevices = btAdapter.getBondedDevices();

		Log.i(LOGTAG, "Total paired "  + pairedDevices.size());
		for (BluetoothDevice btd : pairedDevices) {
			Log.i(LOGTAG, "Device " + btd.getName());
		}
		
		ArrayAdapter<BluetoothDevice> btArrayAdapter = new DeviceListAdapter(this);
		btArrayAdapter.addAll(pairedDevices);
		
		ListView lv = (ListView) findViewById(R.id.deviceView);
		lv.setAdapter(btArrayAdapter);
	}




	@Override
	protected void onDestroy() {
		super.onDestroy();
	}


}